<style scoped>
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .weui-loadmore_line .weui-loadmore__tips {
    background-color: #eee;
  }
  .rj-cell.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell label {
    color: #333;
    font-size: 14px;
    width: 44%;
    display: inline-block;
    padding: 5px 3%;
    text-align: right;
  }
  .rj-cell span {
    font-size: 14px;
    color: #333;
    display: inline-block;
    width: 50%;
  }
  .rj-cell.note label{
    float: left;
  }
  .rj-cell.note span{
    width: 80%;
    display: inline-block;
  }
  .weui-cell {
    background: #fff;
  }
  #acts span {
    font-size: 14px;
  }
  .halfbtn {
    display: inline-block;
    width: 49%;
  }
  .weui-label{
    /*width: 130px;*/
    text-align: left;
  }

  .weui-select {
    height: auto;
    line-height: normal;
  }
  *{
    list-style:none;
  }
  /*body{*/

  /*}*/
  .weui-cell_select {
    padding: 10px 15px;
  }
  .weui-cells__title {
    text-align: left;
  }
  .hide {
    display: none;
  }
  #acts {
    font-size: 0;
  }
  #acts span {
    font-size: 14px;
  }
  input.time {
    border: none;
    font-size: 16px;
    padding-left: 10px;
  }
</style>
<template>
  <div class="oitem">
    <div class="weui-cells__title">扣杂分级标准{{itemNo + 1}}
      <p id="acts" style="float: right;color: #1aad19;" v-if="isLast">
        <span id="addItem" @click="addItem" style="padding-right: 5px;">添加</span>
        <span v-if="itemNo != 0">|</span>
        <span id="delItem" style="padding-left: 5px;" @click="delItem" v-if="itemNo != 0">删除</span>
      </p>
    </div>
    <div class="weui-cell weui-cell_select fir">
      <div class="weui-cell__hd"><label class="weui-label">分级标准</label></div>
      <div class="weui-cell__bd">
        <input type="hidden" :name="'standars[' + itemNo + '].standard'" :value="currStandard.standard">
        <input type="hidden" :name="'standars[' + itemNo + '].standardid'" :value="currStandard.guid">
        <select class="weui-select standard" v-model="currStandard">
          <option value="" disabled>请选择</option>
          <option v-for="(item, index) in standards" :value="item">{{item.standard}}</option>
        </select>
      </div>
    </div>
    <div class="weui-cell" v-if="currStandard.isvaluation == 1">
      <div class="weui-cell__hd"><label class="weui-label">单价</label></div>
      <div class="weui-cell__bd">
          <input class="weui-input price" type="number" style="width: 55%;display: inline-block;" :name="'standars[' + itemNo + '].price'" v-model="price" placeholder="请输入单价">
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'EditContractItem',
  data () {
    return {
      currStandard: '',
      price: '',
      showPrice: false
    }
  },
  props: [
    'itemdata',
    'itemNo',
    'isLast',
    'standards',
    'initItemlen',
  ],
  mounted() {
    let that = this;
    this.setData();

  },
  watch: {
    'itemdata': function (val) {
      this.setData();
    },
  },
  methods: {
    setData: function() {
      this.currStandard = this.standards.filter(item => {
        return item.guid == itemdata.standardid;
      })[0];
      this.price = this.itemdata.price;
    },
    addItem: function() {
      this.$emit('doAddItem');
    },
    delItem: function() {
      this.$emit('doDelItem');
    }
  }
}
</script>
